<?php
/**
 * コメントAPIコントローラー
 *
 * @package  app
 * @extends  Controller
 */
class Controller_Api_Song extends Controller_Apibase {
	/**
	 * 楽曲取得
	 *
	 * @access  public
	 * @return  Response
	 */
	public function action_get() {
		$post = Input::post();
		$json = array();

		$json = $this -> get_song($this -> song_where);

		$query = DB::select(DB::expr('COUNT(*) AS count'));
		$query -> from('favorite');
		$query -> where($this -> member_where_other);
		$query -> where('song_id', $json['song_id']);
		$favorite = $query -> execute() -> as_array();
		if( $favorite[0]['count'] == 0 ) {
			$json['favorite'] = 0;
		} else {
			$json['favorite'] = 1;
		}

		return Response::forge(json_encode($json), D_HTTP_UPDATE);
	}

}
